package com.stendahls.groupbot;

import com.google.wave.api.RobotMessageBundle;
import com.google.wave.api.Wavelet;

import java.util.List;

/**
 *
 */
public class ListGroupCommand extends AbstractCommand {

    public void perform(RobotMessageBundle robotMessageBundle) {

        String result;
        Wavelet wavelet = robotMessageBundle.getWavelet();
        List<String> waveParticipants = wavelet.getParticipants();

        result = "Group members: \n";
        for(String participant : ParticipantManager.getInstance().getGroupParticipants()) {
            boolean added = waveParticipants.contains(participant);
            result += String.format(" - %s (%s) \n", participant,
                    added ? "added" : "not added");

        }

        robotMessageBundle.getWavelet().appendBlip().getDocument().append(result);

    }

}
